package com.example.buildertest.controller;

import com.example.buildertest.model.vo.request.UserRequest;
import com.example.buildertest.model.vo.request.UserUpdateRequest;
import com.example.buildertest.model.vo.response.UserRespoonse;
import com.example.buildertest.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * .
 *
 * @author zhuchenglin
 * @since 2024/3/21 15:09
 */
@RestController
@RequestMapping(value = "/user/")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping(value = "save")
    public Boolean save(@RequestBody UserRequest userRequest) {
        return userService.saveUser(userRequest);
    }

    @GetMapping(value = "getUser/{id}")
    public UserRespoonse getUser(@PathVariable Long id) {
        return userService.getUser(id);
    }

    @PostMapping(value = "update")
    public Boolean updateAge(@RequestBody UserUpdateRequest userRequest) {
        return userService.updateAge(userRequest);
    }
}
